/*
 * @Author: [wsn] [1741415861@qq.com]
 * @Date: 2023-05-06 11:17:01
 * @LastEditors: [wsn] [1741415861@qq.com]
 * @LastEditTime: 2023-05-26 10:49:17
 * @FilePath: \202304fgs_project\src\components\threejsTools\Tools\LoadFbxAnimate.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
import * as THREE from 'three';
/**加载fbx模型 */
export default function LoadfbxAnimate(fbxurl) {//"/fengche-03max.fbx"
    var mixer = null;
    var loader = new FBXLoader(); //创建一个FBX加载器
    loader.load(fbxurl, function (obj) {
      obj.scale.set(0.1, 0.1, 0.1);
      
      mixer = new THREE.AnimationMixer(obj);
      var AnimationAction = mixer.clipAction(obj.animations[0]);
      console.log(AnimationAction,'AnimationAction');
      AnimationAction.play();
      window.threescene.add(obj);
      animate();
    });
    var clock = new THREE.Clock();
    function animate() {
        requestAnimationFrame(animate);
        if(mixer != null){
          mixer.update(clock.getDelta());
        }
    }
}